<template>
<div id="app">
  <router-view ></router-view>
</div>
</template>
<script type="es6">
  var hidden, visibilityChange;
  if (typeof document.hidden !== "undefined") {
    hidden = "hidden";
    visibilityChange = "visibilitychange";
  } else if (typeof document.mozHidden !== "undefined") {
    hidden = "mozHidden";
    visibilityChange = "mozvisibilitychange";
  } else if (typeof document.msHidden !== "undefined") {
    hidden = "msHidden";
    visibilityChange = "msvisibilitychange";
  } else if (typeof document.webkitHidden !== "undefined") {
    hidden = "webkitHidden";
    visibilityChange = "webkitvisibilitychange";
  }
  // 添加监听器
  document.addEventListener(visibilityChange, function() {
    console.log("当前页面是否被隐藏：" + document[hidden]);
  }, false);
export default {
  name: 'App',
  data(){
    return {
    }
  },
  beforeCreate: function() {
    this.proAPI.getJson(this.proAPI.URLS.getAllSysConfig).then((res) =>{
      this.$store.commit("saveConfig",res.data);
      var el = document.getElementById("app");
      el.style.height=window.document.body.offsetHeight+"px";
      el.style.minHeight=window.document.body.offsetHeight+"px";
      // el.style.width=window.document.body.offsetWidth+"px";
      el.style.width="100%";
      // el.style.minWidth=window.document.body.offsetWidth+"px";
      el.style.minWidth=window.document.body.offsetWidth-10+'px';
      // el.style.backgroundImage = 'url("'+this.proAPI.RESOURCE_URL+this.$store.getters.getConfig().clientBgImagePC+'")';
      el.style.backgroundSize = 'cover';
      document.title = "【功能预览版本】"+res.data.webName;
      var link = document.createElement('link');
      link.setAttribute('rel','icon');
      link.setAttribute('type','image/x-icon');
      link.setAttribute('href',this.proAPI.RESOURCE_URL+res.data.webLogo);
      document.head.appendChild(link);
    })
  },
  created: function() {
    console.log("created");
  },
  beforeMount: function() {
    console.log("beforeMount");
  },
  mounted: function() {
    console.log("mounted");
  },
  beforeUpdate: function() {
    console.log("beforeUpdate");
  },
  updated: function() {
    console.log(this.$route);
    console.log("updated");
  },
  activated: function() {
    console.log("activated");
  },
  deactivated: function() {
    console.log("deactivated");
  },
  beforeDestroy: function() {
    console.log("beforeDestroy");
  },
  destroyed: function() {
    console.log("destroyed");
  },
  errorCaptured: function(err, vm, info) {
    if(err){
      if(this.$store.getters.getConfig()==null){
        this.$router.push("/home");
      }
    }else if(vm){
    }else if(info){
    }
  }
}
</script>
<style scoped lang="scss">
  html {
    height: 100%;
    body {
      height: 100%;
      #app {
        min-height:100%;
        /*background-color: #f0f3f6;*/
      }
    }
  }
</style>
